<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组翻转</title>
</head>
<body>
    
</body>

<?php
  $arr1=[1,2,3,4,5];
  //白嫖来的
  function reverse($arr){
    $left = 0;
    $right = count($arr) -1;
    $temp = [];
    while ($left <= $right){
        $temp[$left] = $arr[$right];
        $temp[$right]  = $arr[$left];
        $left++;
        $right--;
    }
    // 排序
    ksort($temp);
    return $temp;
}
// 翻转前
echo '翻转后';
print_r(reverse($arr1));
//   $arr2=[];
//   for($i=count($arr1)-1;$i>=0;$i--){
//       $arr2+=$arr1[$i];
//   }
echo '<br>翻转前';
  print_r($arr1);
?>
</html>